/**
 * Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.shop.web.front;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.modules.cms.entity.Site;
import com.thinkgem.jeesite.modules.cms.service.ArticleDataService;
import com.thinkgem.jeesite.modules.cms.service.ArticleService;
import com.thinkgem.jeesite.modules.cms.service.CommentService;
import com.thinkgem.jeesite.modules.cms.service.LinkService;
import com.thinkgem.jeesite.modules.cms.service.SiteService;
import com.thinkgem.jeesite.modules.cms.utils.CmsUtils;
import com.thinkgem.jeesite.modules.shop.entity.Ad;
import com.thinkgem.jeesite.modules.shop.entity.Goods;
import com.thinkgem.jeesite.modules.shop.service.AdService;
import com.thinkgem.jeesite.modules.shop.service.GoodsCategoryService;
import com.thinkgem.jeesite.modules.shop.service.GoodsService;

/**
 * 网店Controller
 */
@Controller("shopFrontController")
@RequestMapping(value = "${frontPath}")
public class IndexController extends BaseController{
	
	@Autowired
	private ArticleService articleService;
	@Autowired
	private ArticleDataService articleDataService;
	@Autowired
	private LinkService linkService;
	@Autowired
	private CommentService commentService;
	@Autowired
	private GoodsCategoryService goodsCategoryService;
	@Autowired
	private SiteService siteService;
	@Autowired
	private AdService adService;
	@Autowired
	private GoodsService goodsService;
	/**
	 * 网站首页
	 */
	@RequestMapping
	public String index(Model model) {
		Site site = CmsUtils.getSite(Site.defaultSiteId());
		model.addAttribute("site", site);
		model.addAttribute("isIndex", true);
		List<Ad> ads = adService.findListByAdPositionCode("HomeBanner");
		model.addAttribute("ads", ads);
		List<Goods> goodsList = goodsService.findList(new Goods());
		model.addAttribute("goodsList", goodsList);
		//return "index";
		model.addAttribute("isIndex", true);
		System.out.println(site.getTheme()+"/index");
//		return "modules/shop/goods";
		return "/index";
	}
	
}
